package com.example.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import org.testng.annotations.Test;

import com.example.fw.ContactObject;
import com.example.fw.Contacts;

public class ContactCreationTests extends TestBase{
	
	@Test(dataProvider = "contactsFromFile", dataProviderClass = ContactDataGenerator.class)
	public void testContactCreation(ContactObject validContact) throws Exception {
		Contacts oldList = app.getContactHelper().getContacts();		
		app.getContactHelper().createContact(validContact);
		Contacts newList = app.getContactHelper().getContacts();
//		verifyContactAdded(oldList, validContact, newList);
	assertThat(newList, equalTo(oldList.withAdded(validContact)));
		
	}
	
//	@AfterMethod 
	public void testUiAndDbConfirmsWithModel(){
		if(app.getProperty("ui.check") != null){
		Contacts modelList = app.getContactHelper().getContacts();
		Contacts uiList = app.getContactHelper().getUiContacts();
		assertThat(uiList, equalTo(modelList));
		
	}
		if(app.getProperty("db.check") != null){
			Contacts modelList = app.getContactHelper().getContacts();
			Contacts dbList = app.getHibernateHelper().getContacts();
		assertThat(dbList, equalTo(modelList));
		
	}

	

	}	
}
